/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */



package com.wp1.servlets;

//~--- non-JDK imports --------------------------------------------------------

import org.directwebremoting.ServerContext;
import org.directwebremoting.proxy.dwr.Util;

//~--- JDK imports ------------------------------------------------------------

import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
import java.util.logging.Logger;

public class Service {
    protected static final Logger log   = Logger.getLogger("WP1Logger");
    private int                   count = 0;

    public void update(ServerContext wctx) {
        List<Data> messages = new ArrayList<Data>();

        messages.add(new Data("testing" + count++));

        // Collection sessions = wctx.getAllScriptSessions();
        Collection sessions = wctx.getScriptSessionsByPage("/wp1/dwrDemo/BroadcastListener.html");
        Util       utilAll  = new Util(sessions);

        utilAll.addOptions("updates", messages, "value");
    }

        public void update(ServerContext wctx, String filename) {
        List<Data> messages = new ArrayList<Data>();

        messages.add(new Data(filename + count++));

        // Collection sessions = wctx.getAllScriptSessions();
        Collection sessions = wctx.getScriptSessionsByPage("/wp1/dwrDemo/BroadcastListener.html");
        Util       utilAll  = new Util(sessions);

        utilAll.addOptions("updates", messages, "value");
    }
}


//~ Formatted by Jindent --- http://www.jindent.com
